function webpack(options, callback){
    const compiler = createCompiler(options)
   // 1. 遍历entry（入口起点）
    new WebpackOptionsApply().process(options, compiler)
    new LoaderPlugin({}).apply(compiler)
    compiler.run()
}

function createCompiler(options){
    // 合并参数
    // getNormalizedWebpackOptions(options);
   const compiler =  new Compiler()
    return compiler
}


class Compiler {
    constructor(){}

    run(){
        this.compile()
    }

    compile(){
        new Compilation()
    }
}

class Compilation {
    constructor(){
        this.processDependenciesQueue = new AsyncQueue({
            name: "processDependencies",
            parallelism: 100,
            processor: this._processModuleDependencies.bind(this)
        })
        this.factorizeQueue = new AsyncQueue({
            name : "factorize",
            parent: this,addModuleQueue, 
            processor = 
        })
        this.addModuleQueue = []
    }

    addEntry(entry){
        this._addEntryItem(entry)
    }
    
    _addEntryItem(entry){
        this.addModuleTree({dependency: entry})
    }

    addModuleTree(dependency){
        this.addModule()
    }

    addModule(module){
        this.addModuleQueue.add(module)
    }

}


class AsyncQueue{
    constructor({ name, parallelism, processor}){
        this._name = name
        this._parallelism = parallelism || 100
        this._processor = processor

        this._ensureProcessing = this._ensureProcessing.bind(this)

    }

    _ensureProcessing(){
        while(this._activeTasks < this._parallelism){
            const entry = this._queued.depueue()
            if(entry === undefined) break
            this._activeTasks ++ 
            this._startProcessing(entry)
        }
    }

    _startProcessing(entry){
        this._processor(entry.item)
    }
    
}
webpack()